package com.xcdh.commons.utils;

import cn.hutool.json.JSONUtil;
import com.xcdh.domain.vo.UserVo;

public class UserContext {
    private final static ThreadLocal<String> holder = new ThreadLocal<>() ;

    public static void set(String value){
        holder.set(value);
    }

    public static UserVo getUser(){
        String userInfo = holder.get();
        return JSONUtil.toBean(userInfo , UserVo.class) ;
    }

    public static Long getUserId(){
        String userInfo = holder.get();
        return JSONUtil.toBean(userInfo , UserVo.class).getUserId() ;
    }

    public static void remove(){
        holder.remove();
    }

}
